<?php

declare(strict_types=1);

namespace app\admin\validate;

use think\Validate;

class SystemSMChannel extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'name' => 'require|max:256',
        'max_characters_num' => 'integer|gt:1|lte:256',
        'status' => 'require|in:0,1',
        'is_del' => 'in:0,1',
        'creator' => 'integer',
        'updater' => 'integer',
        'create_time' => 'datetime',
        'update_time' => 'datetime',
        'ids' => 'require|array',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'name.require' => '渠道名称必须填写',
        'name.max' => '渠道名称不能超过256个字符',
        'max_characters_num.integer' => '最大字符数必须是整数',
        'max_characters_num.gt' => '最大字符数至少为1',
        'max_characters_num.lte' => '最大字符数不能超过512',
        'status.in' => '状态必须是0或1',
        'is_del.in' => '是否删除必须是0或1',
        'creator.integer' => '创建人必须是整数',
        'updater.integer' => '更新人必须是整数',
        'create_time.datetime' => '创建时间格式不正确',
        'update_time.datetime' => '更新时间格式不正确',
    ];


    protected $scene = [
        'search' => ['name' => 'max:255'],
        'delete' => ['ids' => 'require|array|checkIds'],
        'show' => ['id' => 'require'],
        'status' => ['ids', 'status'],
        'save' => ['name', 'max_characters_num', 'status'],
        'update' => ['id', 'name', 'max_characters_num', 'status']
    ];
}
